using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace DataModels.Models
{
    [Table("District")]
    public partial class District : IComparable
    {
        public District()
        {
            this.Facilities = new List<Facility>();
        }

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int DistrictNo { get; set; }

        /// <summary>
        /// District name 
        /// <remarks>
        /// Naming was adopted since the first autogenerated database mapping.
        /// An attempt to name it to DistrictName will cause some UI component to fail
        /// to display the district name as they are using District1  in their make-up.
        /// </remarks>
        /// </summary>
        [Required]
        [StringLength(50)]
        [Column("District")]
        public string District1 { get; set; }

        public int RegionNo { get; set; }

        [StringLength(50)]
        public string DistrictCode { get; set; }

        //public virtual AutoReminderDistrict AutoReminderDistrict { get; set; }

        [ForeignKey("RegionNo")]
        public virtual Region Region { get; set; }
        public virtual List<Facility> Facilities { get; set; }

        public int CompareTo(object obj)
        {
            if (obj == null) return 1;

            District otherDistrict = obj as District;
            if (otherDistrict != null) return this.District1.CompareTo(otherDistrict.District1);
            else throw new ArgumentException("Object is not a District");
        }
    }
}
